package com.example.demo.controller;

import com.example.demo.pojo.KaoQin;
import com.example.demo.service.impl.KaoQinServiceImpl;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 考勤表(KaoQin)表控制层
 *
 * @author 小虾米大侠
 * @since 2021-03-28 16:37:33
 * @version 1.0
 */
@RestController
@RequestMapping("kaoQin")
@Api(value = "考勤表(KaoQin)管理",tags = "考勤表(KaoQin)管理接口API")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class KaoQinController {
    /**
     * 服务对象
     */
    @Resource
    private KaoQinServiceImpl kaoQinServiceImpl;


    /**
     * 查询毕业预警
     * @param leiXingId1
     * @param leiXingId2
     * @param lciShu
     * @param rciSHu
     * @return
     */
    @RequestMapping(value = "chaXunBiYeYuJing", method = RequestMethod.GET)
    @ApiOperation(value = "列表查询毕业预警接口",notes = "列表查询毕业预警接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "leiXingId1",value = "类型id就填1（冗余懒得改）",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "leiXingId2",value = "类型id就填2",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "lciShu",value = "迟到早退从几次",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "rciSHu",value = "迟到早退到几次",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "llciShu",value = "旷课从几次",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "rrciSHu",value = "旷课到几次",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "lgeShu",value = "挂科个数从",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "rgeShu",value = "挂科个数到",paramType = "query",dataType = "String",required = false)
    })
    public Map<String, Object> chaXunBiYeYuJing(String leiXingId1,String leiXingId2,String lciShu,String rciSHu,String llciShu,
                                                String rrciSHu,String lgeShu,
                                                String rgeShu) {
        return this.kaoQinServiceImpl.chaXunBiYeYuJing(leiXingId1,leiXingId2, lciShu, rciSHu, llciShu,
                 rrciSHu,lgeShu,rgeShu);
    }


    /**
     * 查询考勤分页
     * @param page
     * @param weiGuiLeiXing
     * @param xueShengXueHao
     * @param xingMing
     * @param lweiGuiShiJian
     * @param rweiGuiShiJian
     * @return
     */
    @RequestMapping(value = "chaXunFenYe", method = RequestMethod.GET)
    @ApiOperation(value = "考勤列表查询分页接口",notes = "列表查询分页接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "页码",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "weiGuiLeiXing",value = "违规类型",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "xueShengXueHao",value = "学生学号",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "xingMing",value = "学生姓名",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "lweiGuiShiJian",value = "违规时间从",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "rweiGuiShiJian",value = "违规时间到",paramType = "query",dataType = "String",required = false)
    })
    public Map<String, Object> chaXunFenYe(@RequestParam(name = "page") int page,
                                           String weiGuiLeiXing,
                                           String xueShengXueHao,
                                           String xingMing,
                                           String lweiGuiShiJian,
                                           String rweiGuiShiJian) {
        return this.kaoQinServiceImpl.chaXunFenYe(page,  weiGuiLeiXing,
                 xueShengXueHao,
                 xingMing,
                 lweiGuiShiJian,
                 rweiGuiShiJian);
    }
    
//    /**
//     * 查询所有数据
//     * @return 返回所有数据
//     */
//    @RequestMapping(value = "chaXunAll", method = RequestMethod.GET)
//    @ApiOperation(value = "查询所有数据接口",notes = "查询所有数据接口",httpMethod = "GET")
//    public Map<String, Object> chaXunAll() {
//        return this.kaoQinServiceImpl.chaXunAll();
//    }
//
    /**
     * 通过主键删除单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @RequestMapping(value = "shanChuById", method = RequestMethod.POST)
    @ApiOperation(value = "根据主键删除多条考勤记录的接口",notes = "根据一个主键删除一条**记录的接口",httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "主键",paramType = "query",dataType = "String",required = true),
    })
    public Map<String, Object> shanChuById(@RequestParam("id") String id) {
        return this.kaoQinServiceImpl.shanChuById(id);
    }

    /**
     * 通过主键更新单条数据
     *
     * @param kaoQin 一个数据库对应的POJO数据对象
     * @return 单条数据
     */
    @RequestMapping(value = "gengXinById", method = RequestMethod.POST)
    @ApiOperation(value = "通过主键更新一个考勤记录的接口",notes = "通过主键更新一个**的接口",httpMethod = "POST")
    public Map<String, Object> gengXinById(@RequestBody @ApiParam(name = "kaoQin",value = "pojo模型",required = true) KaoQin kaoQin) {
        return this.kaoQinServiceImpl.gengXinById(kaoQin);
    }

    /**
     * 通过一个pojo对象新增单条数据
     *
     * @param kaoQin 一个数据库对应的POJO数据对象
     * @return 返回插入的主键id
     */
    @RequestMapping(value = "xinZeng", method = RequestMethod.POST)
    @ApiOperation(value = "根据完整记录新增一个考勤记录的接口",notes = "根据完整记录新增一个**的接口",httpMethod = "POST")
    public Map<String, Object> xinZeng(@RequestBody @ApiParam(name = "kaoQin",value = "pojo模型",required = true) KaoQin kaoQin) {
        return this.kaoQinServiceImpl.xinZeng(kaoQin);
    }

}